<?php

namespace App\Http\Controllers\Admin;

use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Illuminate\Foundation\Auth\AuthenticatesUsers;
// use App\Extensions\AuthenticatesLogout;

class LoginController extends Controller
{
    use AuthenticatesUsers;
    // use AuthenticatesUsers,AUthenticatesLogout {
    //     AuthenticatesLogout::logout insteadof AuthenticatesUsers;
    // }

    protected $redirectTo = '/';

    public function __construct()
    {
    	$this -> middleware('guest.admin',['except'=>'logout']);
    }

    public function showLoginForm()
    {
    	return view('admin.login');
    }
    protected function guard()
    {
    	return auth() -> guard('admin');
    }
    public function username()
    {
    	return 'name';
    }
    public function logout(Request $request)
    {
        $this->guard()->logout();

        $request->session()->forget($this->guard()->getName());

        $request->session()->regenerate();

        return redirect('/');
    }

}
